import Re from "./service";
import hyRequest from "./service2";
export const getHomeData = () => {
  return Re.get({ url: "/home/multidata" });
}
//使用完善后的axios封装
//1.get请求
export const getHomeGoods = () => {
 return hyRequest.get({ url: "/home/multidata" });
}

//2.delete请求
export const getDelete = () => {
  return hyRequest.delete({ url: `/users/${userId}`, });
}

//3.post请求
export const getPost = () => {
  return hyRequest.post({
    url: "/users",
    data: {
      name: "John",
      age: 30,
    },
   });
}

//4.put请求
export const getPut = (userId,userdata) => {
  return hyRequest.put({
    url: `/users/${userId}`,
    data: userdata,
   });
}
// 5.使用重试机制;请求失败后，自动重新发起请求,可选参数
export const getHomeGoods2 = () => {
  return hyRequest.get({ url: "/home/multidatas",
    params: { type: "pop", page: 1 },
   }, 5);
};

//6.取消请求 在某些场景下，比如用户切换页面时，你可能需要取消所有未完成的请求：
export const cancelPendingRequests = () => {
 hyRequest.cancelPendingRequests();
}